<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>分类: 技术教程 | 小小程序员</title><meta name="author" content="十一星野"><meta name="copyright" content="十一星野"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="作为一位 Java 后端开发，怎能不会点 Linux 命令？总结了一套非常实用的 Linux 命令（基于 CentOS 7.6），希望对大家有所帮助！  #系统服务管理#systemctl systemctl命令是service和chkconfig命令的组合体，可用于管理系统。   输出系统中各个服务的状态：  1systemctl list-units --type&#x3D;service    查看">
<meta property="og:type" content="article">
<meta property="og:title" content="还在百度Linux命令？推荐一套我用起来特顺手的命令！">
<meta property="og:url" content="https://ko25891wan.gitlab.io/2024/01/faffffcff41d.html">
<meta property="og:site_name" content="小小程序员">
<meta property="og:description" content="作为一位 Java 后端开发，怎能不会点 Linux 命令？总结了一套非常实用的 Linux 命令（基于 CentOS 7.6），希望对大家有所帮助！  #系统服务管理#systemctl systemctl命令是service和chkconfig命令的组合体，可用于管理系统。   输出系统中各个服务的状态：  1systemctl list-units --type&#x3D;service    查看">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png">
<meta property="article:published_time" content="2024-01-21T09:28:37.000Z">
<meta property="article:modified_time" content="2024-02-02T13:40:55.045Z">
<meta property="article:author" content="十一星野">
<meta property="article:tag" content="宅男,热血">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://ko25891wan.gitlab.io/2024/01/faffffcff41d.html"><link rel="preconnect" href="//fastly.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.5.1/css/all.min.css"><link rel="stylesheet" href="https://cdn.staticfile.org/fancyapps-ui/5.0.32/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":1,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.staticfile.org/egjs-infinitegrid/4.11.0/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '分类: 技术教程',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-02-02 21:40:55'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>(()=>{
  const $loadingBox = document.getElementById('loading-box')
  const $body = document.body
  const preloader = {
    endLoading: () => {
      $body.style.overflow = ''
      $loadingBox.classList.add('loaded')
    },
    initLoading: () => {
      $body.style.overflow = 'hidden'
      $loadingBox.classList.remove('loaded')
    }
  }

  preloader.initLoading()
  window.addEventListener('load',() => { preloader.endLoading() })

  if (false) {
    document.addEventListener('pjax:send', () => { preloader.initLoading() })
    document.addEventListener('pjax:complete', () => { preloader.endLoading() })
  }
})()</script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">120</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">4</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">22</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-tools"></i><span> 工具</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/md_editor/"><i class="fa-fw fas fa-pen"></i><span> MDEditor_my</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog-info"><a href="/" title="小小程序员"><span class="site-name">小小程序员</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 清单</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-tools"></i><span> 工具</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/md_editor/"><i class="fa-fw fas fa-pen"></i><span> MDEditor_my</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">还在百度Linux命令？推荐一套我用起来特顺手的命令！</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-01-21T09:28:37.000Z" title="发表于 2024-01-21 17:28:37">2024-01-21</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-02-02T13:40:55.045Z" title="更新于 2024-02-02 21:40:55">2024-02-02</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/">技术教程</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/mall/">mall</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%8A%80%E6%9C%AF%E6%95%99%E7%A8%8B/mall/%E5%8F%82%E8%80%83%E7%AF%87/">参考篇</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.4k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>5分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="还在百度Linux命令？推荐一套我用起来特顺手的命令！"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div><article class="post-content" id="article-container"><blockquote>
<p>作为一位 Java 后端开发，怎能不会点 Linux 命令？总结了一套非常实用的 Linux 命令（基于 CentOS 7.6），希望对大家有所帮助！</p>
</blockquote>
<h2 id="系统服务管理"><a href="#系统服务管理" class="headerlink" title="#系统服务管理"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#%E7%B3%BB%E7%BB%9F%E6%9C%8D%E5%8A%A1%E7%AE%A1%E7%90%86">#</a>系统服务管理</h2><h3 id="systemctl"><a href="#systemctl" class="headerlink" title="#systemctl"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#systemctl">#</a>systemctl</h3><blockquote>
<p><code>systemctl</code>命令是<code>service</code>和<code>chkconfig</code>命令的组合体，可用于管理系统。</p>
</blockquote>
<ul>
<li>输出系统中各个服务的状态：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl list-units --type=service</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_01-e52b2e58.png"></p>
<ul>
<li>查看服务的运行状态：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl status firewalld</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_02-756a34ee.png"></p>
<ul>
<li>关闭服务：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl stop firewalld</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_03-c606063b.png"></p>
<ul>
<li>启动服务：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl start firewalld</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_04-eb8ce98a.png"></p>
<ul>
<li>重新启动服务（不管当前服务是启动还是关闭）：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart firewalld</span><br></pre></td></tr></table></figure>

<ul>
<li>重新载入配置信息而不中断服务：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl reload firewalld</span><br></pre></td></tr></table></figure>

<ul>
<li>禁止服务开机自启动：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl disable firewalld</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_05-c5414c77.png"></p>
<ul>
<li>设置服务开机自启动：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl enable firewalld</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_06-74fd90ab.png"></p>
<h2 id="文件管理"><a href="#文件管理" class="headerlink" title="#文件管理"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#%E6%96%87%E4%BB%B6%E7%AE%A1%E7%90%86">#</a>文件管理</h2><h3 id="ls"><a href="#ls" class="headerlink" title="#ls"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#ls">#</a>ls</h3><p>列出指定目录下的所有文件，列出<code>/</code>目录下的文件：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ls -l /</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_07-366177c2.png"></p>
<h3 id="pwd"><a href="#pwd" class="headerlink" title="#pwd"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#pwd">#</a>pwd</h3><p>获取目前所在工作目录的绝对路径：</p>
<p><img src=""></p>
<h3 id="cd"><a href="#cd" class="headerlink" title="#cd"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#cd">#</a>cd</h3><p>改变当前工作目录：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/local</span><br></pre></td></tr></table></figure>

<p><img src=""></p>
<h3 id="date"><a href="#date" class="headerlink" title="#date"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#date">#</a>date</h3><p>显示或修改系统时间与日期；</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">date &#x27;+%Y-%m-%d %H:%M:%S&#x27;</span><br></pre></td></tr></table></figure>

<p><img src=""></p>
<h3 id="passwd"><a href="#passwd" class="headerlink" title="#passwd"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#passwd">#</a>passwd</h3><p>用于设置用户密码：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">passwd root</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_11-fc029fa4.png"></p>
<h3 id="su"><a href="#su" class="headerlink" title="#su"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#su">#</a>su</h3><p>改变用户身份（切换到超级用户）：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">su -</span><br></pre></td></tr></table></figure>

<h3 id="clear"><a href="#clear" class="headerlink" title="#clear"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#clear">#</a>clear</h3><p>用于清除屏幕信息</p>
<h3 id="man"><a href="#man" class="headerlink" title="#man"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#man">#</a>man</h3><p>显示指定命令的帮助信息：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">man ls</span><br></pre></td></tr></table></figure>

<h3 id="who"><a href="#who" class="headerlink" title="#who"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#who">#</a>who</h3><ul>
<li>查询系统处于什么运行级别：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">who -r</span><br></pre></td></tr></table></figure>

<p><img src=""></p>
<ul>
<li>显示目前登录到系统的用户：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">who -buT</span><br></pre></td></tr></table></figure>

<p><img src=""></p>
<h3 id="free"><a href="#free" class="headerlink" title="#free"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#free">#</a>free</h3><p>显示系统内存状态（单位MB）：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">free -m</span><br></pre></td></tr></table></figure>

<p><img src=""></p>
<h3 id="ps"><a href="#ps" class="headerlink" title="#ps"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#ps">#</a>ps</h3><ul>
<li>显示系统进程运行动态：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ps -ef</span><br></pre></td></tr></table></figure>

<ul>
<li>查看<code>sshd</code>进程的运行动态：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ps -ef | grep sshd</span><br></pre></td></tr></table></figure>

<p><img src=""></p>
<h3 id="top"><a href="#top" class="headerlink" title="#top"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#top">#</a>top</h3><p>查看即时活跃的进程，类似Windows的任务管理器。</p>
<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_16-45769ce0.png"></p>
<h3 id="mkdir"><a href="#mkdir" class="headerlink" title="#mkdir"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#mkdir">#</a>mkdir</h3><p>创建目录：</p>
<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_17-4c3596ed.png"></p>
<h3 id="more"><a href="#more" class="headerlink" title="#more"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#more">#</a>more</h3><p>用于分页查看文件，例如每页10行查看<code>boot.log</code>文件：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">more -c -10 /var/log/boot.log</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_18-3eed35a4.png"></p>
<h3 id="cat"><a href="#cat" class="headerlink" title="#cat"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#cat">#</a>cat</h3><p>用于查看文件，例如查看Linux启动日志文件文件，并标明行号：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cat -Ab /var/log/boot.log</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_19-f00e1482.png"></p>
<h3 id="touch"><a href="#touch" class="headerlink" title="#touch"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#touch">#</a>touch</h3><p>用于创建文件，例如创建<code>text.txt</code>文件：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">touch text.txt</span><br></pre></td></tr></table></figure>

<p><img src=""></p>
<h3 id="rm"><a href="#rm" class="headerlink" title="#rm"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#rm">#</a>rm</h3><ul>
<li>删除文件：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rm text.txt</span><br></pre></td></tr></table></figure>

<ul>
<li>强制删除某个目录及其子目录：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rm -rf testdir/</span><br></pre></td></tr></table></figure>

<p><img src=""></p>
<h3 id="cp"><a href="#cp" class="headerlink" title="#cp"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#cp">#</a>cp</h3><p>用于拷贝文件，例如将<code>test1</code>目录复制到<code>test2</code>目录</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cp -r /mydata/tes1 /mydata/test2</span><br></pre></td></tr></table></figure>

<h3 id="mv"><a href="#mv" class="headerlink" title="#mv"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#mv">#</a>mv</h3><p>用于移动或覆盖文件：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mv text.txt text2.txt</span><br></pre></td></tr></table></figure>

<h2 id="压缩与解压"><a href="#压缩与解压" class="headerlink" title="#压缩与解压"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#%E5%8E%8B%E7%BC%A9%E4%B8%8E%E8%A7%A3%E5%8E%8B">#</a>压缩与解压</h2><h3 id="tar"><a href="#tar" class="headerlink" title="#tar"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#tar">#</a>tar</h3><ul>
<li>将<code>/etc</code>文件夹中的文件归档到文件<code>etc.tar</code>（并不会进行压缩）：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -cvf /mydata/etc.tar /etc</span><br></pre></td></tr></table></figure>

<ul>
<li>用<code>gzip</code>压缩文件夹<code>/etc</code>中的文件到文件<code>etc.tar.gz</code>：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -zcvf /mydata/etc.tar.gz /etc</span><br></pre></td></tr></table></figure>

<ul>
<li>用<code>bzip2</code>压缩文件夹<code>/etc</code>到文件<code>/etc.tar.bz2</code>：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -jcvf /mydata/etc.tar.bz2 /etc</span><br></pre></td></tr></table></figure>

<p><img src=""></p>
<ul>
<li>分页查看压缩包中内容（gzip）：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -ztvf /mydata/etc.tar.gz |more -c -10</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_24-3d771f9d.png"></p>
<ul>
<li>解压文件到当前目录（gzip）：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -zxvf /mydata/etc.tar.gz</span><br></pre></td></tr></table></figure>

<ul>
<li>解压文件到指定目录（gzip）：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tar -zxvf /mydata/etc.tar.gz -C /mydata/etc</span><br></pre></td></tr></table></figure>

<h2 id="磁盘和网络管理"><a href="#磁盘和网络管理" class="headerlink" title="#磁盘和网络管理"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#%E7%A3%81%E7%9B%98%E5%92%8C%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86">#</a>磁盘和网络管理</h2><h3 id="df"><a href="#df" class="headerlink" title="#df"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#df">#</a>df</h3><p>查看磁盘空间占用情况：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">df -hT</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_25-2eadcd66.png"></p>
<h3 id="dh"><a href="#dh" class="headerlink" title="#dh"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#dh">#</a>dh</h3><p>查看当前目录下的文件及文件夹所占大小：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">du -h --max-depth=1 ./*</span><br></pre></td></tr></table></figure>

<p><img src=""></p>
<h3 id="ifconfig"><a href="#ifconfig" class="headerlink" title="#ifconfig"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#ifconfig">#</a>ifconfig</h3><p>显示当前网络接口状态：</p>
<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_27-1322230c.png"></p>
<h3 id="netstat"><a href="#netstat" class="headerlink" title="#netstat"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#netstat">#</a>netstat</h3><ul>
<li>查看当前路由信息：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">netstat -rn</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_28-01eb6632.png"></p>
<ul>
<li>查看所有有效TCP连接：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">netstat -an</span><br></pre></td></tr></table></figure>

<ul>
<li>查看系统中启动的监听服务：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">netstat -tulnp</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_29-497bdcb7.png"></p>
<ul>
<li>查看处于连接状态的系统资源信息：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">netstat -atunp</span><br></pre></td></tr></table></figure>

<h3 id="wget"><a href="#wget" class="headerlink" title="#wget"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#wget">#</a>wget</h3><p>从网络上下载文件</p>
<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_30-c77bb975.png"></p>
<h2 id="文件上传下载"><a href="#文件上传下载" class="headerlink" title="#文件上传下载"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E4%B8%8B%E8%BD%BD">#</a>文件上传下载</h2><ul>
<li>安装上传下载工具<code>lrzsz</code>；</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install -y lrzsz</span><br></pre></td></tr></table></figure>

<ul>
<li>上传文件，输入以下命令<code>XShell</code>会弹出文件上传框；</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rz</span><br></pre></td></tr></table></figure>

<ul>
<li>下载文件，输入以下命令<code>XShell</code>会弹出文件保存框；</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sz fileName</span><br></pre></td></tr></table></figure>

<h2 id="软件的安装与管理"><a href="#软件的安装与管理" class="headerlink" title="#软件的安装与管理"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#%E8%BD%AF%E4%BB%B6%E7%9A%84%E5%AE%89%E8%A3%85%E4%B8%8E%E7%AE%A1%E7%90%86">#</a>软件的安装与管理</h2><h3 id="rpm"><a href="#rpm" class="headerlink" title="#rpm"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#rpm">#</a>rpm</h3><blockquote>
<p>RPM是<code>Red-Hat Package Manager</code>的缩写，一种Linux下通用的软件包管理方式，可用于安装和管理<code>.rpm</code>结尾的软件包。</p>
</blockquote>
<ul>
<li>安装软件包：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm -ivh nginx-1.12.2-2.el7.x86_64.rpm</span><br></pre></td></tr></table></figure>

<ul>
<li>模糊搜索软件包：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm -qa | grep nginx</span><br></pre></td></tr></table></figure>

<ul>
<li>精确查找软件包：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm -qa nginx</span><br></pre></td></tr></table></figure>

<ul>
<li>查询软件包的安装路径：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm -ql nginx-1.12.2-2.el7.x86_64</span><br></pre></td></tr></table></figure>

<ul>
<li>查看软件包的概要信息：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm -qi nginx-1.12.2-2.el7.x86_64</span><br></pre></td></tr></table></figure>

<ul>
<li>验证软件包内容和安装文件是否一致：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm -V nginx-1.12.2-2.el7.x86_64</span><br></pre></td></tr></table></figure>

<ul>
<li>更新软件包：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm -Uvh nginx-1.12.2-2.el7.x86_64</span><br></pre></td></tr></table></figure>

<ul>
<li>删除软件包：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">rpm -e nginx-1.12.2-2.el7.x86_64</span><br></pre></td></tr></table></figure>

<h3 id="yum"><a href="#yum" class="headerlink" title="#yum"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#yum">#</a>yum</h3><blockquote>
<p>Yum是<code>Yellow dog Updater, Modified</code>的缩写，能够在线自动下载RPM包并安装，可以自动处理依赖性关系，并且一次安装所有依赖的软件包，非常方便！</p>
</blockquote>
<ul>
<li>安装软件包：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install nginx</span><br></pre></td></tr></table></figure>

<ul>
<li>检查可以更新的软件包：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum check-update</span><br></pre></td></tr></table></figure>

<ul>
<li>更新指定的软件包：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum update nginx</span><br></pre></td></tr></table></figure>

<ul>
<li>在资源库中查找软件包信息：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum info nginx*</span><br></pre></td></tr></table></figure>

<ul>
<li>列出已经安装的所有软件包：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum info installed</span><br></pre></td></tr></table></figure>

<ul>
<li>列出软件包名称：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum list nginx*</span><br></pre></td></tr></table></figure>

<ul>
<li>模糊搜索软件包：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum search nginx</span><br></pre></td></tr></table></figure>

<h2 id="用户管理"><a href="#用户管理" class="headerlink" title="#用户管理"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#%E7%94%A8%E6%88%B7%E7%AE%A1%E7%90%86">#</a>用户管理</h2><h3 id="用户信息查看"><a href="#用户信息查看" class="headerlink" title="#用户信息查看"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#%E7%94%A8%E6%88%B7%E4%BF%A1%E6%81%AF%E6%9F%A5%E7%9C%8B">#</a>用户信息查看</h3><ul>
<li>查看用户信息：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cat /etc/passwd</span><br></pre></td></tr></table></figure>

<ul>
<li>用户信息格式如下（密码已过滤）：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"># 用户名:密码:用户标识号:组标识号:组注释性描述:主目录:默认shell</span><br><span class="line">root:x:0:0:root:/root:/bin/bash</span><br><span class="line">macro:x:1000:982:macro:/home/macro:/bin/bash</span><br></pre></td></tr></table></figure>

<ul>
<li>查看用户组信息：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cat /etc/group</span><br></pre></td></tr></table></figure>

<ul>
<li>用户组信息格式如下：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"># 组名:密码:组标识号:组内用户列表</span><br><span class="line">root:x:0:</span><br><span class="line">docker:x:982:macro,andy</span><br></pre></td></tr></table></figure>

<h3 id="passwd-1"><a href="#passwd-1" class="headerlink" title="#passwd"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#passwd-1">#</a>passwd</h3><p>用于设置用户密码：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">passwd root</span><br></pre></td></tr></table></figure>

<p><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/obsition/linux_command_11-fc029fa4.png"></p>
<h3 id="su-1"><a href="#su-1" class="headerlink" title="#su"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#su-1">#</a>su</h3><p>改变用户身份（切换到超级用户）：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"># 切换到root用户</span><br><span class="line">su -</span><br><span class="line"># 切换到macro用户</span><br><span class="line">su macro</span><br></pre></td></tr></table></figure>

<h3 id="groupadd"><a href="#groupadd" class="headerlink" title="#groupadd"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#groupadd">#</a>groupadd</h3><p>添加用户组，使用<code>-g</code>可以设置用户组的标志号：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">groupadd -g 1024 macrozheng</span><br></pre></td></tr></table></figure>

<h3 id="groupdel"><a href="#groupdel" class="headerlink" title="#groupdel"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#groupdel">#</a>groupdel</h3><p>删除用户组：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">groupdel macrozheng</span><br></pre></td></tr></table></figure>

<h3 id="useradd"><a href="#useradd" class="headerlink" title="#useradd"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#useradd">#</a>useradd</h3><p>添加用户，<code>-u</code>设置标志号，<code>-g</code>设置主用户组：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">useradd -u 1024 -g macrozheng macro</span><br></pre></td></tr></table></figure>

<h3 id="usermod"><a href="#usermod" class="headerlink" title="#usermod"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#usermod">#</a>usermod</h3><p>修改用户所属用户组：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">usermod -g docker macro</span><br></pre></td></tr></table></figure>

<h3 id="userdel"><a href="#userdel" class="headerlink" title="#userdel"></a><a target="_blank" rel="noopener" href="https://www.macrozheng.com/mall/reference/linux_command.html#userdel">#</a>userdel</h3><p>删除用户，使用<code>-r</code>可以删除用户主目录：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">userdel macro -r</span><br></pre></td></tr></table></figure></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://ko25891wan.gitlab.io">十一星野</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://ko25891wan.gitlab.io/2024/01/faffffcff41d.html">https://ko25891wan.gitlab.io/2024/01/faffffcff41d.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://ko25891wan.gitlab.io" target="_blank">小小程序员</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2024/01/d9e47931d83a.html" title="还在手动整合Swagger？Swagger官方Starter是真的香！"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">还在手动整合Swagger？Swagger官方Starter是真的香！</div></div></a></div><div class="next-post pull-right"><a href="/2024/01/e4961137ef62.html" title="还在百度Docker命令？推荐一套我用起来特顺手的命令！"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">还在百度Docker命令？推荐一套我用起来特顺手的命令！</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://qiniu.ko25891wan.top/%E6%97%A5%E8%AE%B0%E8%BD%AF%E4%BB%B6/%E5%A4%B4%E5%83%8F/%E7%81%B0%E5%A4%AA%E7%8B%BC.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">十一星野</div><div class="author-info__description">归途也还可爱</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">120</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">4</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">22</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io"><i class="fab fa-github"></i><span>关注我</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="https://gitlab.com/ko25891wan/ko25891wan.gitlab.io" target="_blank" title="Gitlab"><i class="fab fa-gitlab" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:ko25891wan@outlook.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%B3%BB%E7%BB%9F%E6%9C%8D%E5%8A%A1%E7%AE%A1%E7%90%86"><span class="toc-number">1.</span> <span class="toc-text">系统服务管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#systemctl"><span class="toc-number">1.1.</span> <span class="toc-text">systemctl</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E7%AE%A1%E7%90%86"><span class="toc-number">2.</span> <span class="toc-text">文件管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#ls"><span class="toc-number">2.1.</span> <span class="toc-text">ls</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#pwd"><span class="toc-number">2.2.</span> <span class="toc-text">pwd</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#cd"><span class="toc-number">2.3.</span> <span class="toc-text">cd</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#date"><span class="toc-number">2.4.</span> <span class="toc-text">date</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#passwd"><span class="toc-number">2.5.</span> <span class="toc-text">passwd</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#su"><span class="toc-number">2.6.</span> <span class="toc-text">su</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#clear"><span class="toc-number">2.7.</span> <span class="toc-text">clear</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#man"><span class="toc-number">2.8.</span> <span class="toc-text">man</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#who"><span class="toc-number">2.9.</span> <span class="toc-text">who</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#free"><span class="toc-number">2.10.</span> <span class="toc-text">free</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#ps"><span class="toc-number">2.11.</span> <span class="toc-text">ps</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#top"><span class="toc-number">2.12.</span> <span class="toc-text">top</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mkdir"><span class="toc-number">2.13.</span> <span class="toc-text">mkdir</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#more"><span class="toc-number">2.14.</span> <span class="toc-text">more</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#cat"><span class="toc-number">2.15.</span> <span class="toc-text">cat</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#touch"><span class="toc-number">2.16.</span> <span class="toc-text">touch</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#rm"><span class="toc-number">2.17.</span> <span class="toc-text">rm</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#cp"><span class="toc-number">2.18.</span> <span class="toc-text">cp</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mv"><span class="toc-number">2.19.</span> <span class="toc-text">mv</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8E%8B%E7%BC%A9%E4%B8%8E%E8%A7%A3%E5%8E%8B"><span class="toc-number">3.</span> <span class="toc-text">压缩与解压</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#tar"><span class="toc-number">3.1.</span> <span class="toc-text">tar</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%A3%81%E7%9B%98%E5%92%8C%E7%BD%91%E7%BB%9C%E7%AE%A1%E7%90%86"><span class="toc-number">4.</span> <span class="toc-text">磁盘和网络管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#df"><span class="toc-number">4.1.</span> <span class="toc-text">df</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#dh"><span class="toc-number">4.2.</span> <span class="toc-text">dh</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#ifconfig"><span class="toc-number">4.3.</span> <span class="toc-text">ifconfig</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#netstat"><span class="toc-number">4.4.</span> <span class="toc-text">netstat</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#wget"><span class="toc-number">4.5.</span> <span class="toc-text">wget</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E4%B8%8B%E8%BD%BD"><span class="toc-number">5.</span> <span class="toc-text">文件上传下载</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%BD%AF%E4%BB%B6%E7%9A%84%E5%AE%89%E8%A3%85%E4%B8%8E%E7%AE%A1%E7%90%86"><span class="toc-number">6.</span> <span class="toc-text">软件的安装与管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#rpm"><span class="toc-number">6.1.</span> <span class="toc-text">rpm</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#yum"><span class="toc-number">6.2.</span> <span class="toc-text">yum</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%94%A8%E6%88%B7%E7%AE%A1%E7%90%86"><span class="toc-number">7.</span> <span class="toc-text">用户管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%94%A8%E6%88%B7%E4%BF%A1%E6%81%AF%E6%9F%A5%E7%9C%8B"><span class="toc-number">7.1.</span> <span class="toc-text">用户信息查看</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#passwd-1"><span class="toc-number">7.2.</span> <span class="toc-text">passwd</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#su-1"><span class="toc-number">7.3.</span> <span class="toc-text">su</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#groupadd"><span class="toc-number">7.4.</span> <span class="toc-text">groupadd</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#groupdel"><span class="toc-number">7.5.</span> <span class="toc-text">groupdel</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#useradd"><span class="toc-number">7.6.</span> <span class="toc-text">useradd</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#usermod"><span class="toc-number">7.7.</span> <span class="toc-text">usermod</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#userdel"><span class="toc-number">7.8.</span> <span class="toc-text">userdel</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/02/c60470b9a892.html" title="Java集合使用注意事项总结">Java集合使用注意事项总结</a><time datetime="2024-02-03T04:58:22.000Z" title="发表于 2024-02-03 12:58:22">2024-02-03</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/02/81fb7a201f29.html" title="无题">无题</a><time datetime="2024-02-03T03:15:31.812Z" title="发表于 2024-02-03 11:15:31">2024-02-03</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/5737c1ec69a9.html" title="Wed Jan 17 2024 00:00:00 GMT+0800 (中国标准时间)">Wed Jan 17 2024 00:00:00 GMT+0800 (中国标准时间)</a><time datetime="2024-01-31T06:56:16.000Z" title="发表于 2024-01-31 14:56:16">2024-01-31</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/f510db7d2f19.html" title="Spring常见面试题总结">Spring常见面试题总结</a><time datetime="2024-01-31T06:55:58.000Z" title="发表于 2024-01-31 14:55:58">2024-01-31</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/01/9be065e9f288.html" title="redis 面试">redis 面试</a><time datetime="2024-01-31T06:55:55.000Z" title="发表于 2024-01-31 14:55:55">2024-01-31</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2023 - 2024 By 十一星野</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.staticfile.org/fancyapps-ui/5.0.32/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.staticfile.org/instant.page/5.2.0/instantpage.min.js" type="module"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>